<?php


namespace app\common\model;


use Exception;
use think\Db;
use think\Model;

class Feedback extends Model
{

    // 表名
    protected $table = 'feedback';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = null;
    protected $deleteTime = null;

    public function addLog($params)
    {
        extract($params);
        Db::startTrans();
        try {
            $this->create($params);
            Db::rollback();
            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => []
            ];
        }catch (Exception $e) {
            Db::rollback();
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => $e->getLine()
            ];
        }
    }
}